using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using YayiMgr.Ability.Docking.DictionaryApp;
using YayiMgr.Ability.Docking.DictionaryApp.Dto;

namespace YayiMgr.Web.System
{
    [ApiController]
    [Route("api/[controller]")]
    public class DictionaryTypeController : ControllerBase
    {
        public IDictionaryTypeServicer dicTypeServicer {get;set;}
        // GET: api/<ValuesController>
        [HttpGet]
        public async Task<List<DictionaryTypeDto>> Get()
        {
            return await dicTypeServicer.GetAllDictionaryTypes() ;
        }

        // GET api/<ValuesController>/5
        [HttpGet("{id}")]
        public async Task<DictionaryTypeDto> Get(Guid id)
        {
            return await dicTypeServicer.GetAllDictionaryTypesById(id);
        }

        // POST api/<ValuesController>
        [HttpPost]
        public async Task<DictionaryTypeDto> Post(DictionaryTypeCreateDto value)
        {
            return await dicTypeServicer.AddDictionaryType(value);
        }

        // PUT api/<ValuesController>/5
        [HttpPut("{id}")]
        public async void Put(Guid id, DictionaryTypeUpdateDto value)
        {
            await dicTypeServicer.UpdateDictionaryType(id, value);
        }

        // DELETE api/<ValuesController>/5
        [HttpDelete("{id}")]
        public async void Delete(Guid id)
        {
            await dicTypeServicer.DeleteDictionaryType(id);
        }
    }
}